<template>
  <div class="my-allSearch">
    <div class="my-search">
      <i @click="goback" class="iconfont icon-xiangzuo btnLeft"></i>
      <div class="search">
        <i class="iconfont icon-sousuo"></i>
        <input type="text" v-model="v1" placeholder="搜你想搜的" />
      </div>
      <p @click="mySearch">搜索</p>
    </div>
    <div class="hot" v-if="show">
      <h3>热门搜索</h3>
      <ul class="hot-list">
        <li v-for="(e, i) in hotArray" v-bind:key="i">{{ e }}</li>
        <li>{{ v1 }}</li>
      </ul>
    </div>
    <div class="hot-search">
      <ul>
        <li v-for="(item, index) in dataJson" v-bind:key="index">
          {{ item.content }}
        </li>
      </ul>
    </div>
  </div>
</template>
<script>
export default {
  name: "mySearch",
  data() {
    return {
      hotArray: [
        "哲理",
        "励志",
        "情感",
        "生活",
        "伤感",
        "动漫",
        "搞笑",
        "追星",
        "友谊",
        "英文",
        "早安",
        "生日",
      ],
      v1: "",
      dataJson: {},
      show: true,
    };
  },
  methods: {
    goback() {
      this.$router.go(-1);
    },
    mySearch() {
      //
      // this.show = !this.show;
      //
      this.dataJson = {};
      //
      if (this.v1 == "哲理" ||this.v1 =='') {
        this.funData1();
      } else if (this.v1 == "励志") {
        this.funData2();
      } else if (this.v1 == "情感") {
        this.funData3();
      }
    },
    funData1() {
      let pro = axios.get("./data/dataSearch1.json");
      pro.then((res) => {
        console.log(res.data.data.list[0].content);
        this.dataJson = res.data.data.list;
         this.show = !this.show;
      //
      });
    },
    funData2() {
      let pro = axios.get("./data/dataSearch2.json");
      pro.then((res) => {
        console.log(res);
        this.dataJson = res.data.data.list;
         this.show = !this.show;
      //
      });
    },
    funData3() {
      let pro = axios.get("./data/dataSearch3.json");
      pro.then((res) => {
        console.log(res);
        this.dataJson = res.data.data.list;
         this.show = !this.show;
      //
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.my-allSearch{
  background: #F8F8F8;
  // position: fixed;
  // top: 0;
  // left: 0;
  width: 100%;
  height: 667px;
}
.my-search {
  z-index: 20;
  width: 100%;
  height: 46px;
  background: #7ab4ff;
  position: fixed;
  left: 0;
  top: 0;
  display: flex;
  justify-content: space-around;
  align-items: center;
  .search {
    //   width: 296px;
    height: 36px;
    line-height: 36px;
    border-radius: 20px;
    background: #fff;
    display: flex;

    i {
      font-size: 24px;
      margin-left: 15px;
      color: #ccc;
    }
    input {
      height: 36px;
      width: 200px;
      border-top-right-radius: 20px;
      border-bottom-right-radius: 20px;
      margin-left: 10px;
      vertical-align: middle;
      font-weight: 600;
      color: #b2b2b2;
      padding: 0;
      box-shadow: none;
      /*聚焦input的蓝色边框*/
      outline: none;
      /*textarea 禁止拖拽*/
      resize: none;
      /*去除边框*/
      border: none;
      //   &:-webkit-input-placeholder{
      //      color: #7ab4ff !important;
      //   }
      &:focus {
        // border: 0;
        border-color: rgb(255, 255, 255);
      }
    }
  }
}

p {
  height: 100%;
  line-height: 46px;
  font-size: 18px;
  color: #fff;
  padding: 0 10px;
}
.btnLeft {
  width: 46px;
  height: 46px;
  font-size: 46px;
  color: #fff;
}
.hot {
  
  margin-top: 46px;
  h3 {
    font-size: 20px;
    // padding: 10px 0;
  }
  .hot-list {
    width: 90%;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    //  align-items: center;
    //  justify-content: space-evenly;
    li {
      width: 60px;
      text-align: center;
      height: 25px;
      line-height: 25px;
      border-radius: 10px;
      background: #ffffff;
      font-size: 14px;
      margin-right: 5px;
      margin-top: 10px;
    }
    li:nth-child(5n) {
      margin-right: 0px;
    }
  }
}
.hot-search {
  width: 100%;
  height: 100%;
  background: #F8F8F8;
  margin-top: 46px;
  padding: 10px 0 30px;
  z-index: 99;
  ul {
   margin-top: 10px;
    li {
      width: 90%;
      margin: 10px auto;
      text-align: center;
      height: 50px;
      line-height: 1.6;
      font-size: 16px;
      background: #fff;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      // -webkit-line-clamp: 2;
      overflow: hidden;
      border-radius: 6px;
      text-indent:20px;
      box-shadow: 0 0 5px #ccc;
      padding: 5px;
    }
  }
}
</style>